﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BathhouseService.Models.SqlModels;


namespace BathhouseService.CURD.ViewModels.PackageServiceSettingsVMs
{
    public partial class PackageServiceSettingsListVM2 : BasePagedListVM<PackageServiceSettings_View, PackageServiceSettingsSearcher>
    {




        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeAction("PackageServiceSettings", "Create2", "新建","新建", GridActionParameterTypesEnum.NoId,"CURD").SetOnClickScript("CreateReport"),
                this.MakeStandardAction("PackageServiceSettings", GridActionStandardTypesEnum.Edit, "修改","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageServiceSettings", GridActionStandardTypesEnum.Delete, "删除", "CURD",dialogWidth: 800),
            };
        }

        protected override IEnumerable<IGridColumn<PackageServiceSettings_View>> InitGridHeader()
        {
            return new List<GridColumn<PackageServiceSettings_View>>{
                this.MakeGridHeader(x => x.Name_view),
                this.MakeGridHeader(x => x.Names_view),
                this.MakeGridHeader(x => x.Count),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<PackageServiceSettings_View> GetSearchQuery()
        {
            var query = DC.Set<PackageServiceSettings>()
                .Where(x => x.PackageServiceId == Searcher.PackageServiceId)
                .Select(x => new PackageServiceSettings_View
                {
				    ID = x.ID,
                    Name_view = x.PackageService.Name,
                    Names_view = x.ValueAddedServices.Names,
                    Count = x.Count,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

  
}
